<template>
  <el-row class="container">
    <el-col
      :xs="12"
      :sm="12"
      :md="6"
      :lg="6"
      class="card_col"
      v-for="(item, index) in plantMaterialList"
      :key="index"
    >
      <div class="card_item" @click="goDetail(item)">
        <div class="img_wraper">
          <img :src="imgUrl + item.img" />
        </div>
        <div class="item_title">{{ item.scientificName }}</div>
        <div class="item_desc">
          <span>{{ item.description }}</span>
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: "ConItem",
  components: {},
  props: {
    plantMaterialList: {
      type: Array,
      default: [],
    },
  },
  computed: {
    imgUrl() {
      return process.env.VUE_APP_IP || ''
    },
  },
  methods: {
    goDetail(plantObj) {
      const id = plantObj.id
      this.$router.push({ path: '/pdetail', query: { plantId: id } })
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  margin-top: 18px;
  // max-height: 400px;

  .card_col {
    padding: 5px;
  }
}
.card_item {
  position: relative;
  height: 270px;
  cursor: pointer;
  overflow: hidden;
  background: #fff;
  border-radius: 5px;
  border-color: rgba(0, 0, 0, 0.05);
  box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: box-shadow 1s ease 0s;

  &:hover {
    bottom: 5px;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.2);
  }
  .img_wraper {
    // flex: 1;
    height: 200px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }

  .item_title {
    padding: 8px;
    width: 100%;
    height: 35px;
    line-height: 26px;
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .item_desc {
    font-size: 14px;
    height: 35px;
    line-height: 16px;
    color: #666;
    padding: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media screen and (max-width: 992px) {
  .card_item {
    height: 200px;
    margin-bottom: 10px;
  }
}
</style>
